package cn.hbu.zlfw.patent.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import cn.hbu.zlfw.admin.entity.ScienceExpert;
import cn.hbu.zlfw.exchange.entity.Chat;
import cn.hbu.zlfw.exchange.entity.Poster;
import cn.hbu.zlfw.research.entity.Researcher;

/**
 * 
 * @ClassName: Patent 
 * @Description: 专利表
 * @author 王鹏伟<1223443289@qq.com>
 * @date 2017年11月2日 下午4:42:30  
 * @version V1.0
 */
@Entity 
@Table(name="t_patent")
public class Patent implements Serializable{

	private static final long serialVersionUID = -2065287356030959603L;
	
	@Id
	@Column(name="id",length=32)
	@GeneratedValue(generator="UUID_KEY")
	@GenericGenerator(name="UUID_KEY",strategy="uuid.hex")
	private String id;
    @Column(name = "guid", length = 36 ,insertable=false ,updatable=false)
    private String num;
	
	
	@Column(name="name",length=80,nullable=false)
	private String name;
	/**
	 * 所属学科编码字符（eg.10,11,12）
	 */
	@Column(name="subjectTypes",nullable=false)
	private String subjectTypes;		
	/**
	 * 专利的状态：由专利转状态码确定
	 */
	@Column(name="patentState",length=20,nullable=false)
	private Integer patentState;
	/**
	 * 是否允许跨校协助:1表示允许0表示不允许
	 */
	@Column(name="allowCorss",length=20,nullable=false)
	private Integer allowCorss;		
	
	@Column(name="delState",length=20,nullable=false)
	private Integer delState;	//删除标志 1表示已删除 0表示未删除
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="createTime",nullable=false)
	private Date createTime;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="updateTime",nullable=false)
	private Date updateTime;
	
	@ManyToOne(cascade= {CascadeType.MERGE,CascadeType.PERSIST})	//级联策略
	@JoinColumn(name="r_id")
	@JsonIgnore
	private Researcher researcher;
	/**
	 * mappedBy属性表示放弃维护关系操作，在此patent放弃维护关系交给patentApply
	 */
	@OneToMany(mappedBy="patent")
	@JsonIgnore
	private Set<PatentApply> patentApplies;		//专利交底书
	
	@OneToMany(mappedBy="patent")
	@JsonIgnore
	private Set<PatentSynergy> patentSynergies;	//专利协同申请书
	
	@ManyToOne(cascade= {CascadeType.MERGE,CascadeType.PERSIST})	//级联策略
	@JoinColumn(name="science_id")
	@JsonIgnore
	private ScienceExpert scienceExpert;			//科技服务人员，接单人员
	
	@ManyToMany(cascade= {CascadeType.MERGE,CascadeType.PERSIST})
	@JoinTable(name="t_patent_science",                       		//指定第三张表
	       joinColumns={@JoinColumn(name="patent_id")},             //本表与中间表的外键对应
	       inverseJoinColumns={@JoinColumn(name="science_id")})	
	@JsonIgnore//另一张表与中间表的外键的对应关系
	private Set<ScienceExpert> scienceExperts;			//科技服务人员,协助接单人员
	
	@Column(name="sfApply",length=20,nullable=false)
	private int sfApply;		//是否提交专利交底书	： 1表示提交0反之
	
	@Column(name="sfSynergy",length=20,nullable=false)
	private int sfSynergy;		//是否提交专利协同申请  ：1表示提交0反之
	
	@Column(name="finishSummary",length=3500)
	private String finishSummary;	//结项意见
	
	@Column(name="finishReportFileName")
	private String finishReportFileName; //结项报告文件名称,用逗号隔开
	
	@OneToMany(mappedBy="patent")
	@JsonIgnore
	private Set<Poster> poster;		//交流的问题
	
	@OneToMany(mappedBy="patent")
	@JsonIgnore
	private Set<Chat> chat;		//在线交流
	
	
	
	private int communicationNum = 0;	//交流次数
	
	public int getCommunicationNum() {
		return communicationNum;
	}
	public void setCommunicationNum(int communicationNum) {
		this.communicationNum = communicationNum;
	}
	public String getFinishSummary() {
		return finishSummary;
	}
	public void setFinishSummary(String finishSummary) {
		this.finishSummary = finishSummary;
	}
	
	public String getFinishReportFileName() {
		return finishReportFileName;
	}
	public void setFinishReportFileName(String finishReportFileName) {
		this.finishReportFileName = finishReportFileName;
	}
	public Researcher getResearcher() {
		return researcher;
	}
	public void setResearcher(Researcher researcher) {
		this.researcher = researcher;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public String getSubjectTypes() {
		return subjectTypes;
	}

	public void setSubjectTypes(String subjectTypes) {
		this.subjectTypes = subjectTypes;
	}

	public Integer getPatentState() {
		return patentState;
	}
	public void setPatentState(Integer patentState) {
		this.patentState = patentState;
	}
	public Integer getAllowCorss() {
		return allowCorss;
	}

	public void setAllowCorss(Integer allowCorss) {
		this.allowCorss = allowCorss;
	}

	public Integer getDelState() {
		return delState;
	}

	public void setDelState(Integer delState) {
		this.delState = delState;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	public Set<PatentApply> getPatentApplies() {
		return patentApplies;
	}

	public void setPatentApplies(Set<PatentApply> patentApplies) {
		this.patentApplies = patentApplies;
	}

	public Set<PatentSynergy> getPatentSynergies() {
		return patentSynergies;
	}

	public void setPatentSynergies(Set<PatentSynergy> patentSynergies) {
		this.patentSynergies = patentSynergies;
	}
	
	public int getSfApply() {
		return sfApply;
	}

	public void setSfApply(int sfApply) {
		this.sfApply = sfApply;
	}

	public int getSfSynergy() {
		return sfSynergy;
	}

	public void setSfSynergy(int sfSynergy) {
		this.sfSynergy = sfSynergy;
	}
	
	public ScienceExpert getScienceExpert() {
		return scienceExpert;
	}

	public void setScienceExpert(ScienceExpert scienceExpert) {
		this.scienceExpert = scienceExpert;
	}

	public Set<ScienceExpert> getScienceExperts() {
		return scienceExperts;
	}

	public void setScienceExperts(Set<ScienceExpert> scienceExperts) {
		this.scienceExperts = scienceExperts;
	}
	
	public Set<Poster> getPoster() {
		return poster;
	}
	public Set<Chat> getChat() {
		return chat;
		}
		public void setPoster(Set<Poster> poster) {
		this.poster = poster;
	}
	public void setChat(Set<Chat> chat) {
		this.chat = chat;
	}
	
	public String getNum() {
		return num;
	}
	public void setNum(String num) {
		this.num = num;
	}
	@Override
	public String toString() {
		return "Patent [id=" + id + ", name=" + name + ", subjectTypes=" + subjectTypes + ", patentState=" + patentState
				+ ", allowCorss=" + allowCorss + ", delState=" + delState + ", createTime=" + createTime
				+ ", updateTime=" + updateTime + ", sfApply=" + sfApply + ", sfSynergy=" + sfSynergy
				+ ", finishSummary=" + finishSummary + ", finishReportFileName=" + finishReportFileName + "]";
	}
}
